local mou__jianxiong = fk.CreateSkill {

  name = "joy_mou__jianxiong",

  tags = {  },

}



mou__jianxiong:addEffect(fk.Damaged, {
  name = "joy_mou__jianxiong",
  anim_type = "masochism",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
     return target == player and player:hasSkill(mou__jianxiong.name) and ((data.card and target.room:getCardArea(data.card) == Card.Processing) or 2 - player:getMark("@joy_mou__jianxiong") > 0)
  end,
  on_use = function(self, event, target, player, data)
    if data.card and target.room:getCardArea(data.card) == Card.Processing then
      player.room:obtainCard(player, data.card, true, fk.ReasonJustMove)
    end
    local num = 2 - player:getMark("@joy_mou__jianxiong")
    if num > 0 then
      player:drawCards(num, mou__jianxiong.name)
    end
    local choices = {"getMark"}
    local n = "#joy_mou__jianxiong-getMark"
      if player:getMark("@joy_mou__jianxiong") ~= 0 then
        table.insert(choices,"removeMark")
        n = "#joy_mou__jianxiong-choose"
      end
    if player.room:askForSkillInvoke(player, mou__jianxiong.name, nil, n) then
      local choice = player.room:askForChoice(player,choices,mou__jianxiong.name)
      if choice == "getMark" then
        player.room:addPlayerMark(player,  "@joy_mou__jianxiong", 1)
      else
        player.room:removePlayerMark(player, "@joy_mou__jianxiong", 1)
      end
    end
  end,
})

mou__jianxiong:addEffect(fk.GameStart, {
  name = "#joy_mou__jianxiong_gamestart",
  events = {fk.GameStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill("joy_mou__jianxiong")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("joy_mou__jianxiong")
    local choice = room:askForChoice(player, {"0", "1", "2"}, "joy_mou__jianxiong", "#joy_mou__jianxiong-choice")
    room:addPlayerMark(player,  "@joy_mou__jianxiong", tonumber(choice))
  end,
})

return mou__jianxiong